package com.ljy.my_study.util;

import com.ljy.my_study.lintcode.翻转链表.TestMain.ListNode;

/** 
* @author James
* @date 2018年9月28日 
*/
public class ListNodeUtil {
	public static ListNode createListNode(int[] nums) {
		ListNode head=null;
		ListNode nowNode=null;
		int len=nums.length;
		for(int i=0;i<=len-1;i++) {
			if(i==0) {
				nowNode=new ListNode(nums[i]);
				head=nowNode;
			}
			if(i!=len-1) {
				nowNode.next=new ListNode(nums[i+1]);
				nowNode=nowNode.next;
			}
		}
		return head;
	}
	
	public static class ListNode {
		public int val;
		public ListNode next;

		public ListNode(int x) {
			val = x;
			next = null;
		}

		public ListNode(int x,ListNode next) {
			this.val = x;
			this.next = next;
		}

		@Override
		public String toString() {
			return "{\"val\":\"" + val + "\",\"next\":\"" + next + "\"} ";
		}
		
	}
}
